package cn.edu.scau.cmi.zhuangjunsheng.comprehensiveExperiment;

import cn.edu.scau.cmi.zhuangjunsheng.abstractFactory.domainAbstractClass.Meat;
import cn.edu.scau.cmi.zhuangjunsheng.abstractFactory.factory.AbstractFactory;
import cn.edu.scau.cmi.zhuangjunsheng.abstractFactory.factory.AonongFactory;
import cn.edu.scau.cmi.zhuangjunsheng.abstractFactory.factory.TianbangFactory;
import cn.edu.scau.cmi.zhuangjunsheng.abstractFactory.factory.WensFactory;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class AbstractFactoryUI {

	@FXML
	private TextField tf1;
	@FXML
	private TextField tf2;
	@FXML
	private TextArea ta;
	
	AbstractFactory factory=null;
	
	@FXML
	public void onTF(ActionEvent av) throws Exception {
		
		String brandKind = tf1.getText();  
		switch(brandKind){
		case "Wens": factory=new WensFactory();break;
		case "Tianbang": factory=new TianbangFactory();break;
		case "Aonong": factory=new AonongFactory();break;
		//default:ta.appendText("sorry, your input is not correct\n");
		
		//factory.createBeef();
		}
		
		String meatType = tf2.getText(); 
		Meat meat=null;
		switch(meatType) {
		case "beef": meat= factory.createBeef();break;
		case "pork": meat= factory.createPork();break;
		case "chicken": meat=factory.createChicken();break;
		default:ta.appendText("sorry, your input is not correct\n");
		
		}
		if(meat!=null) {
			//System.out.println("!@#!@#!@#!");
			ta.appendText(meat.cook1());
		}
		
	} 
	
}
